<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>天气预报管理</title>
    <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
    <script type="text/javascript" src="js/ext-base.js"></script>
    <script type="text/javascript" src="js/ext-all.js"></script>
</head>
<body style="padding:10px;">
<div id="north-div"></div>
<div id="center"></div>
<script type="text/javascript">
Ext.onReady(function(){
	//编码方式
	Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8';
	//使用表单提示
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';

	var _weather_status_period = [['1','晴'],
	                              ['2','多云'],
	                              ['3','阴'],
	                              ['4','阵雨'],
	                              ['5','雷阵雨'],
	                              ['6','小雨'],
	                              ['7','中雨'],
	                              ['8','大雨'],
	                              ['9','暴雨'],
	                              ['10','大暴雨'],
	                              ['11','特大暴雨'],
	                              ['12','小雨-中雨'],
	                              ['13','中雨-大雨'],
	                              ['14','大雨-暴雨'],
	                              ['15','暴雨-大暴雨'],
	                              ['16','大暴雨-特大暴雨']];

    var _wsp = _psw = {};
    
    for(var i=0;i<_weather_status_period.length;i++){
    	_wsp[''+(i+1)] = _weather_status_period[i][1];
    	_psw[_weather_status_period[i][1]] = ''+i;
    }
	
    var ds = new Ext.data.Store({//这是数据源
        proxy : new Ext.data.HttpProxy({url:'weather/list.action'}),
        reader: new Ext.data.JsonReader({
            root:'topics',
            totalProperty: 'totalCount',
            id: 'id'
            },[
               	{name:"id"},
				{name:"date"},	
				{name:"message"},
				{name:"typePeriod1"},
				{name:"statusPeriod1"},
				{name:"typePeriod2"},
				{name:"statusPeriod2"},
				{name:"typePeriod3"},
				{name:"statusPeriod3"},
				{name:"typePeriod4"},
				{name:"statusPeriod4"},
				{name:"typePeriod5"},
				{name:"statusPeriod5"},
				{name:"typePeriod6"},
				{name:"statusPeriod6"},
				{name:"typePeriod7"},
				{name:"statusPeriod7"},
				{name:"typePeriod8"},
				{name:"statusPeriod8"},
				{name:"typePeriod9"},
				{name:"statusPeriod9"},
				{name:"typePeriod10"},
				{name:"statusPeriod10"},
				{name:"typePeriod11"},
				{name:"statusPeriod11"},
				{name:"typePeriod12"},
				{name:"statusPeriod12"},
				{name:"typeHalf1"},
				{name:"statusHalf1"},
				{name:"typeHalf2"},
				{name:"statusHalf2"},
				{name:"typeHalf3"},
				{name:"statusHalf3"},
				{name:"typeHalf4"},
				{name:"statusHalf4"},
				{name:"updateTime"},
				{name:"currentTypePeriod"},
				{name:"version"},
				{name:"tem"}
            ])
    });

    var colModel = new Ext.grid.ColumnModel([//定义列
         	{header:'ID',width:50,sortable:true,dataIndex:'id'},
         	{header:'日期', width:100,sortable:true,dataIndex:'date'},
         	{header:'版本', width:100,sortable:true,dataIndex:'version'}
        ]);
    
    var tb = new Ext.Toolbar('north-div');//创建一个工具条
   
    tb.add({
        id:'addWeatherBtn',
        text: '添加',
        handler: newUser
        },{
        text: '编辑',
        handler: editUser
        },{
        text: '删除',
        handler: delUser
    });
 
    var grid = new Ext.grid.GridPanel({//列表
                id:'data_grid',
                border:false,
                region:'center',
                loadMask: true,
                el:'center',
                title:'条目列表',
                store: ds,
                cm: colModel,
                autoScroll: true,
                bbar: new Ext.PagingToolbar({
                    pageSize: 20,
                    store: ds,
                    displayInfo: true,
                    displayMsg: '第{0} 到 {1} 条数据 共{2}条',
                    emptyMsg: "没有数据"
                })
            });
    
    var top = new Ext.FormPanel({//这里是搜索表单
        buttonAlign:'right',
        labelWidth:70,
        region:'north',
        height:100,
        frame:true,
        title: '搜索',
        items: [{
                    layout: 'form',
                    items: [{
                    	name:'weather.date',
						id:'weather_date',
						xtype:'datefield',
						format:'Y-m-d',
						fieldLabel:'日期',
                        anchor:'20%'
                    }]
        }],
        buttons: [{
            text: '搜索',
            handler:function(){loadList();}
        }]
    });
    
    var viewport = new Ext.Viewport({
        layout:'border',
        items:[{
              border:false,
              region:'north',
              contentEl:'north-div',
              tbar:tb,
              height:26
            },{
                layout:"border",
                region:'center',
                border:false,
                items:[top,grid]
                }
        ]}
    );
    
    var loadList = function(){
	    ds.load({params:{start:0, limit:20},callback:function(r,options,success){
		    if(!success){//没取到数据时返回的success=false
		        grid.store.removeAll();//清除原有数据
		  }
	    }});
    }
    
    loadList();
    
    // 这里很关键，如果不加，翻页后搜索条件就变没了，这里的意思是每次数据载入前先把搜索表单值加上去，这样就做到了翻页保留搜索条件了
    ds.on('beforeload',function(){
        Ext.apply(
        this.baseParams,
        {
            'weather.date':Ext.get('weather_date').dom.value
        });
    });
    
    var simple = new Ext.FormPanel({
        labelWidth:100,
        frame:true,
        width: 550,
        autoScroll :true,
        items: [{
    		layout:'column',
    		items:[{
            		columnWidth:0.55,
            		layout:'form',
            		items:{
        	        	name:'weather.date',
        				id:'edit_weather_date',
        				xtype:'datefield',
        				format:'Y-m-d',
        				fieldLabel:'日期'
        	        }
        		},{
                	columnWidth:0.45,
                	layout:'form',
                	items:{
        			    xtype:'textfield',
	                	name:'weather.message',
	                	id:'weather_message',
	                	fieldLabel:'相关说明'
                	}
        		}]
        },{
    		layout:'column',
    		items:[{
            		columnWidth:0.55,
            		layout:'form',
            		items:{
        		        hiddenName:'weather.currentTypePeriod',
        		        id:'weather_currentTypePeriod',
	        	        fieldLabel: '当前天气状况',
	        	        xtype:'combo',
	        	        store:{
	            	        xtype:'arraystore',
	    					fields:['id','val'],
	    					data:_weather_status_period
	        	         },
	        	        valueField: 'id',
			            displayField:'val',
			            mode: 'local',
			            value:'1',
			            forceSelection:true,
			            typeAhead: true,
			            triggerAction: 'all'
        			}
        		},{
                	columnWidth:0.45,
                	layout:'form',
                	items:{
        			    xtype:'textfield',
	                	name:'weather.tem',
	                	id:'weather_tem',
	                	fieldLabel:'当前温度'
                	}
        		}]
        },{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod1',
            		        id:'weather_statusPeriod1',
		        	        fieldLabel: '[00:00 ~ 02:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod1',
		                	id:'weather_typePeriod1',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
            },{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod2',
            		        id:'weather_statusPeriod2',
		        	        fieldLabel: '[02:00 ~ 04:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod2',
		                	id:'weather_typePeriod2',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
            },{
	       		layout:'column',
	       		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
	           		        hiddenName:'weather.statusPeriod3',
	           		        id:'weather_statusPeriod3',
		        	        fieldLabel: '[04:00 ~ 06:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
	           			}
	           		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
	           			    xtype:'textfield',
		                	name:'weather.typePeriod3',
		                	id:'weather_typePeriod3',
		                	fieldLabel:'风力和温度'
	                	}
	           		}]
	        },{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod4',
            		        id:'weather_statusPeriod4',
		        	        fieldLabel: '[06:00 ~ 08:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod4',
		                	id:'weather_typePeriod4',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod5',
            		        id:'weather_statusPeriod5',
		        	        fieldLabel: '[08:00 ~ 10:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod5',
		                	id:'weather_typePeriod5',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod6',
            		        id:'weather_statusPeriod6',
		        	        fieldLabel: '[10:00 ~ 12:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod6',
		                	id:'weather_typePeriod6',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod7',
            		        id:'weather_statusPeriod7',
		        	        fieldLabel: '[12:00 ~ 14:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod7',
		                	id:'weather_typePeriod7',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod8',
            		        id:'weather_statusPeriod8',
		        	        fieldLabel: '[14:00 ~ 16:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod8',
		                	id:'weather_typePeriod8',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod9',
            		        id:'weather_statusPeriod9',
		        	        fieldLabel: '[16:00 ~ 18:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod9',
		                	id:'weather_typePeriod9',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod10',
            		        id:'weather_statusPeriod10',
		        	        fieldLabel: '[18:00 ~ 20:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod10',
		                	id:'weather_typePeriod10',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod11',
            		        id:'weather_statusPeriod11',
		        	        fieldLabel: '[20:00 ~ 22:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod11',
		                	id:'weather_typePeriod11',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusPeriod12',
            		        id:'weather_statusPeriod12',
		        	        fieldLabel: '[22:00 ~ 24:00] ',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typePeriod12',
		                	id:'weather_typePeriod12',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
            		        hiddenName:'weather.statusHalf1',
            		        id:'weather_statusHalf1',
		        	        fieldLabel: '未来第一日上午',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            			    xtype:'textfield',
		                	name:'weather.typeHalf1',
		                	id:'weather_typeHalf1',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
        					hiddenName:'weather.statusHalf2',
    		        		id:'weather_statusHalf2',
		        	        fieldLabel: '未来第一日下午',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            				xtype:'textfield',
	                		name:'weather.typeHalf2',
		                	id:'weather_typeHalf2',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
        					hiddenName:'weather.statusHalf3',
    		        		id:'weather_statusHalf3',
		        	        fieldLabel: '未来第二日上午',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            				xtype:'textfield',
	                		name:'weather.typeHalf3',
		                	id:'weather_typeHalf3',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
        		layout:'column',
        		items:[{
	            		columnWidth:0.55,
	            		layout:'form',
	            		items:{
        					hiddenName:'weather.statusHalf4',
    		        		id:'weather_statusHalf4',
		        	        fieldLabel: '未来第二日下午',
		        	        xtype:'combo',
		        	        store:{
		            	        xtype:'arraystore',
		    					fields:['id','val'],
		    					data:_weather_status_period
		        	         },
		        	        valueField: 'id',
				            displayField:'val',
				            mode: 'local',
				            value:'1',
				            forceSelection:true,
				            typeAhead: true,
				            triggerAction: 'all'
            			}
            		},{
	                	columnWidth:0.45,
	                	layout:'form',
	                	items:{
            				xtype:'textfield',
	                		name:'weather.typeHalf4',
		                	id:'weather_typeHalf4',
		                	fieldLabel:'风力和温度'
	                	}
            		}]
			},{
                xtype:'hidden',
                id:'weather_id',
                name:'weather.id'
            }]
    });
    
    
    var doClose = function(){
        addDialog.hide();
    }

    var doAdd = function(){
    	//提交到服务器操作
        simple.form.doAction('submit',{
          url:'weather/add.action',//文件路径
          method:'post',//提交方法post或get
          //提交成功的回调函数
          success:function(response,options){
        	  addDialog.hide();
        	  if(Ext.get('weather_id').dom.value != null&&Ext.get('weather_id').dom.value != ''){
	        	  Ext.get('weather_id').dom.value = '';
	        	  Ext.Msg.alert('编辑成功','  恭喜您成功地修改了天气预报信息！',function(){ds.reload();});
              }else{
	        	  Ext.Msg.alert('添加成功','  恭喜您成功地添加了新的天气预报！',function(){ds.reload();});
              }
          },
          //提交失败的回调函数
          failure:function(response,options){
        	  Ext.Msg.alert('错误','请检查您的输入是否为空,如果多次确认无法成功请与系统管理员联系!！');
          }
        });
    }
    
    var addDialog;

    var initEditDialog = function(title){
        if(!addDialog){
        	addDialog = new Ext.Window({
     			layout:'fit',
     			width:630,
     			height:450,
     			closeAction:'hide',
     			plain:true,
     			buttons:[{text:'保存',disabled:false,handler:doAdd},{text:'关闭',handler:doClose}],
     			items:simple
         });
        }
        addDialog.setTitle(title);
    }
    
    function newUser() {
    	initEditDialog('新增天气信息');
    	try{Ext.get('weather_id').dom.value = '';}catch(e){}
        addDialog.show('addWeatherBtn');
    }
    
    function editUser() {
        var s = grid.getSelectionModel().getSelections();
        if (s.length>1) {
            Ext.Msg.alert('出错啦','您选择了 '+s.length+' 条记录,目前只支持一次编辑一条记录！');
            return false;
        }
        if (s.length==0) {
            Ext.Msg.alert('出错啦','你还没有选择要操作的记录！');
            return false;
        }
  	    initEditDialog('编辑天气信息');
  	    addDialog.show('addWeatherBtn');
  	    Ext.get('weather_id').dom.value = s[0].data.id;
  	    Ext.get('edit_weather_date').dom.value = s[0].data.date;
  	    Ext.get('weather_tem').dom.value = s[0].data.tem;

  	    Ext.getCmp('weather_currentTypePeriod').setValue(s[0].data['currentTypePeriod']);
  	    Ext.getCmp('weather_currentTypePeriod').hiddenField.value = s[0].data['currentTypePeriod'];
  	    Ext.get('weather_message').dom.value = s[0].data.message;
  	  
  	  
  	    for(var i=1;i<13;i++){
  	    	Ext.getCmp('weather_statusPeriod'+i).setValue(s[0].data['statusPeriod'+i]);
  	  	    Ext.getCmp('weather_statusPeriod'+i).hiddenField.value = s[0].data['statusPeriod'+i];
	  	    Ext.get('weather_typePeriod'+i).dom.value = s[0].data['typePeriod'+i];
  	  	}
  	    for(var i=1;i<5;i++){
  	    	Ext.getCmp('weather_statusHalf'+i).setValue(s[0].data['statusHalf'+i]);
  	  	    Ext.getCmp('weather_statusHalf'+i).hiddenField.value = s[0].data['statusHalf'+i];
	  	    Ext.get('weather_typeHalf'+i).dom.value = s[0].data['typeHalf'+i];
  	  	}
    }

    var getIds = function(g){
    	var s = g.getSelectionModel().getSelections();
    	 if (s.length==0) {
             return false;
         }
         var ids = [];
         for(var i=0;i<s.length;i++){
             ids.push(s[i].data.id);
         }
         return ids.join(',');
    }

    var delSucc = function(result){
    	 loadList();
    }
    
    function delUser() {
        var ids = getIds(grid);
        if (ids) {
            Ext.Msg.confirm('确认', '真的要删除吗？', function(btn){
                if (btn == 'yes'){
                    Ext.Ajax.request({
                       url: 'weather/del.action?weatherIds='+ids,
                       success:delSucc
                    });
                }
            });       
        } else {
            Ext.Msg.alert('出错啦','你还没有选择要操作的记录！');
        }
    }
});
</script>
</body>
</html>